﻿@model Model.AppUserList
@{
    ViewBag.Title = "LocationGoods";
    Layout = "~/Views/Shared/_JQBaseLayOut.cshtml";
}
@using Model

@section JQscriptSection{
    <script type="text/javascript">
        $(document).ready(function () {
            InitGrid();

        });

        HandleDom.ClassTriggerClick("icon-add", function () {
            $('#hiddenLOCATIONID').val();
            HandleDialog.OpenDialogByAdd('dlg', '添加货位商品关联', function () {
                HandleData.ClearForm('location');
                $('#locationCode').attr("readonly", false);
                $('#txtGoodsCode').attr("readonly", false);
                $('#valids').combobox('setValue', '1');

            });
        });

        HandleDom.ClassTriggerClick("icon-edit", function () {
            var row = HandleData.GetDataGridSelected("dg");
            edit(row);
        });


        HandleDom.ClassTriggerClick("icon-exporter", function () {
            var form = $('#query');
            var rows = $(".pagination-page-list option:selected").text();
            var page = $("input[size='2']").val();
            form.form('submit', {
                url: '@Url.Content("~/LocationGoods/ExportExcelLocationGoods")' + '?page=' + page + '&rows=' + rows,
                success: function (data) {
                    eval('data=' + data);
                    if (data.success) {
                        layer.alert('执行成功!', 9);
                    } else {
                        layer.msg(data.msg, 2);
                    }
                }
            });

        });

        //编辑
        function edit(row) {
            HandleData.ClearForm('location');
            HandleDialog.OpenDialog(row, 'dlg', '编辑货位商品关联', function () {
                $('#locationCode').val(row.LOCATIONCODE);
                $('#txtGoodsCode').val(row.GOODSCODE);
                $('#hiddenLOCATIONID').val(row.LOCATIONID);
                $('#hiddenGOODSID').val(row.GOODSID);
                $('#hiddenLOCATIONGOODSID').val(row.LOCATIONGOODSID);
                HandleData.SetValueComboBox('valids', row.STATUS);
                $('#hiddenStatus').val(row.STATUS);
                $('#txtRemark').val(row.REMARK);

                $('#locationCode').attr("readonly", true);
                $('#txtGoodsCode').attr("readonly", true);

            });
        }

        function saveData(isClose) {
            HandleRequest.submitForm('location', '@Url.Action("SaveData", "LocationGoods")', function (data) {
                eval('data=' + data);
                if (data.success == true) {
                    layer.alert('执行成功!', 9);
                    InitGrid();
                    HandleDialog.CloseDialog('dlg');
                } else {
                    layer.msg(data.msg, 1);
                }
            });
        }

        function InitGrid() {
            var txtSLOCATIONCODE = $('#txtSLOCATIONCODE').val();
            var txtSGOODSCODE = $('#txtSGOODSCODE').val();
            var txtSGOODSNAME = $('#txtSGOODSNAME').val();
            var selectValid = $('#valid').combobox('getValue');

            queryParams = {
                locationCode: txtSLOCATIONCODE,
                goodsCode: txtSGOODSCODE,
                goodsName: txtSGOODSNAME,
                valid: selectValid
            }
            HandleData.InitDataGrid('dg', '/LocationGoods/InitJsonResult', 'toolbar', queryParams, 'LOCATIONGOODSID', true, function (data) {
                $("#dg").datagrid('hideColumn', "LOCATIONGOODSID");
                $("#dg").datagrid('hideColumn', "LOCATIONID");
                $("#dg").datagrid('hideColumn', "GOODSID");
            },
                function (rowIndex, rowData) {//双击
                    edit(rowData);
                });
        }


        //导入货位商品关联信息
        function ImpotExcel() {
            var form = $('#import');
            form.form('submit', {
                url: '@Url.Content("~/LocationGoods/ImportLocationGoods")',
                success: function (data) {
                    eval('data=' + data);
                    if (data.success) {
                        layer.alert('导入成功!', 9);
                        $('#btnExecl').show();
                        InitGrid();
                    } else {
                        layer.alert(data.msg, 3);
                    }
                }
            });
        }

    </script>
}

<body style="background-color: ButtonFace; font-size: 17px">
    <div class="easyui-panel" title="查询条件" style="height: 130px; padding: 5px; background: #fafafa; width: 1700px;">
        <form id="query" method="post">
            <table>
                <tr>
                    <td>货位编码:
                    </td>
                    <td>
                        <input id="txtSLOCATIONCODE" name="txtSLOCATIONCODE" style="width: 154px" />
                    </td>
                    <td>商品编码:
                    </td>
                    <td>
                        <input id="txtSGOODSCODE" name="txtSGOODSCODE" style="width: 154px" />
                    </td>
                    <td>商品名称:
                    </td>
                    <td>
                        <input id="txtSGOODSNAME" name="txtSGOODSNAME" style="width: 154px" />
                    </td>
                    <td>是否有效:
                    </td>
                    <td colspan="2">
                        <select id="valid" class="easyui-combobox" name="valid" style="width: 154px;">
                            <option value="1">有效</option>
                            <option value="0">无效</option>
                        </select>
                    </td>
                    <td></td>
                    <td>
                        <a id="btnSerach" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="InitGrid()">查询</a>
                    </td>

                </tr>
            </table>
        </form>
        <form id="import" method="post" enctype="multipart/form-data">
            <table>
                <tr>
                    <td>
                        <input id="FileUpload" type="file" name="files" style="width: 250px; height: 24px; background: White"
                            class="easyui-validatebox" />
                        <a id="btnGet" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-excel'" onclick="ImpotExcel()">导入</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    <div style="min-height: 720px; width: 1700px;">
        <table id="dg" title="货位商品关联信息" style="min-height: 600px;">
            <thead>
                <tr>
                    <th data-options="field:'LOCATIONGOODSID',width:30">货位商品关联ID</th>
                    <th data-options="field:'LOCATIONID',width:50">货位ID</th>
                    <th data-options="field:'GOODSID',width:50">商品ID</th>
                    <th data-options="field:'LOCATIONCODE',width:50">货位编码</th>
                    <th data-options="field:'GOODSCODE',width:50">商品编码</th>
                    <th data-options="field:'GOODSNAME',width:50">商品名称</th>
                    <th data-options="field:'WAREHOUSENAME',width:30">仓库</th>
                    <th data-options="field:'CELLNO',width:30">库位</th>
                     <th data-options="field:'GSTATUS',width:30,sortable:true,formatter:function(value, rowData, rowIndex){ return FormatData.formatGoodsStatus(value);}">商品状态</th>
                    <th data-options="field:'STATUS',width:30,sortable:true,formatter:function(value, rowData, rowIndex){ return FormatData.formatValid(value);}">状态</th>
                    <th data-options="field:'REMARK',width:30">备注</th>
                </tr>
            </thead>
        </table>
    </div>
    <div id="dlg" class="easyui-dialog" style="width: 620px; height: 200px; top: 300px; left: 400px; padding: 2px"
        data-options="closed:true,buttons:'#dlg-buttons',modal:true">
        <form id="location" method="post">
            <table>
                <tr>
                    <td>货位:
                    </td>
                    <td>
                        <input id="hiddenLOCATIONGOODSID" name="hiddenLOCATIONGOODSID" type="hidden" />
                        <input id="hiddenGOODSID" name="hiddenGOODSID" type="hidden" />
                        <input id="hiddenLOCATIONID" name="hiddenLOCATIONID" type="hidden" />
                        <input id="hiddenStatus" name="hiddenStatus" type="hidden" />
                        <input id="locationCode" name="locationCode" style="width: 154px" class="easyui-validatebox" data-options="required:true" />
                    </td>
                    <td>商品编码:
                    </td>
                    <td colspan="2">
                        <input id="txtGoodsCode" name="txtGoodsCode" class="easyui-validatebox" style="width: 154px" data-options="required:true" />
                    </td>
                </tr>
                <tr>
                    <td>是否有效:
                    </td>
                    <td colspan="2">
                        <select id="valids" class="easyui-combobox" name="valids" style="width: 154px;">
                            <option value="1">有效</option>
                            <option value="0">无效</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>备注:
                    </td>
                    <td colspan="4">
                        <input id="txtRemark" name="txtRemark" maxlength="255" style="width: 520px" />
                    </td>
                </tr>
                <tr>
                    <td colspan="5">
                        <a id="btnSave" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="saveData(true)">保存</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    @Html.Partial("~/Views/Shared/_PartialToolbar.cshtml", new Toolbar
{
    GridName = "dg",
    GridType = "datagrid",
    ToolbarName = "toolbar",
    FunctionModule = new Dictionary<string, List<FunctionModule>>()
    {
        {"Function",new List<FunctionModule>()
            {
              new FunctionModule(){Name = "Add",IsEnable =true },
              new FunctionModule(){Name = "Edit",IsEnable =true },
              new FunctionModule(){Name = "Remove",IsEnable =false },
              new FunctionModule(){Name = "Reload",IsEnable =false },
              new FunctionModule(){Name = "Collapse",IsEnable =false },
              new FunctionModule(){Name = "Exporter",IsEnable =true },
              
            }
        }
    }
})

</body>

